Page({
  data: {
    isSearchOn: false,
    searchTxt: null,
    date: null,
    dateSelected: 0,
    isDown: false,
    week: ['周日','周一','周二','周三','周四','周五','周六','今天'],
    doctors: [
      {
        name: '王医生',
        position: '主任医师',
        intro: '擅长：脊柱外科常见病的临床诊治，颈肩痛、腰腿痛、脊柱退行性疾病、脊柱外伤、脊柱感染、脊柱畸形，脊柱肿瘤。主攻方向:腰椎退行性疾病的微创治疗。',
        isDown: false,
        available: true,
        path: '../../../assets/imgs/docHeader0.png'
      },
      {
        name: '刘医生',
        position: '主任医师',
        intro: '擅长：颈椎病、腰椎间盘突出症、腰腿痛、人工关节置换等骨科疾病的诊断和治疗;主攻方向:颈椎病、关节炎、复杂创伤骨折。',
        isDown: false,
        available: true,
        path: '../../../assets/imgs/docHeader1.png'
      },
      {
        name: '刘医生',
        position: '副主任医师',
        intro: '擅长：颈肩痛、腰腿痛、肢体无力、骨质疏松、脊柱骨折等疾病的诊治。主攻方向:颈、胸、腰椎疾病的个性化治疗。',
        isDown: false,
        available: true,
        path: '../../../assets/imgs/docHeader2.png'
      },
      {
        name: '张医生',
        position: '普诊',
        intro: '擅长：颈肩痛、腰腿痛相关疾病诊疗,麻木无力、活动困难、行走不稳相关疾病诊疗,骨质疏松。',
        isDown: true,
        available: false,
        path: '../../../assets/imgs/docHeader3.png'
      },
      {
        name: '李医生',
        position: '主任医师/硕导',
        intro: '擅长：髋膝关节周围骨折及各种退行性关节炎的诊断与治疗，擅长四肢及骨盆复杂骨折的手术治疗，另外对足踝外科的治疗有深入的研究。主攻方向:足踝外科，髋膝关节置换和创伤外科。',
        isDown: false,
        available: false,
        path: '../../../assets/imgs/docHeader4.png'
      }
    ],
    selectedFamily: null
  },
  searchOn(){
    this.setData({isSearchOn: true});
  },
  searchOff(){
    this.setData({isSearchOn: false});
  },
  onShow(){
    var d = new Date();
    let date = [];
    date.push({
      date: d.getDate(),
      day: 7
    });
    for(var i = 0; i < 6; i++){
      d.setDate(d.getDate() + 1);
      date.push({
        date: d.getDate(),
        day: d.getDay()
      })
    }
    this.setData({date: date});
    let selectedFamily = getApp().globalData.selectedFamily;
    let x = selectedFamily[0];
    let y = selectedFamily[1];
    this.setData({selectedFamily: getApp().globalData.families[x][y]});
  },
  selectDate(event){
    let date = event.currentTarget.dataset.index;
    this.setData({dateSelected: date});
  },
  stretch(event){
    let id = event.currentTarget.dataset.index;
    let target = 'doctors[' + id + '].isDown';
    this.setData({[target]: !this.data.doctors[id].isDown})
  },
  toAppointment(event){
    let id = event.currentTarget.dataset.index;
    getApp().globalData.selectedDoctor = id;
    wx.navigateTo({
      url: '../doctorPage/doctorPage',
    })
  }
})